#include <iostream>
#include <stack>

// 两个栈实现一个队列
class MyQueue
{
public:
    MyQueue() {}
    void Push(int value)
    {
        while (s2.empty() == false)
        {
            s1.push(s2.top());
            s2.pop();
        }
        s1.push(value);
    }
    void Pop()
    {
        while (s1.empty() == false)
        {
            s2.push(s1.top());
            s1.pop();
        }
        s2.pop();
    }
    bool IsEmpty()
    {
        return s1.empty() && s2.empty();
    }

    int GetTop()
    {
        while (s1.empty() == false)
        {
            s2.push(s1.top());
            s1.pop();
        }
        return s2.top();
    }

private:
    std::stack<int> s1;
    std::stack<int> s2;
};
int main()
{
    MyQueue q;
    q.Push(1);
    q.Push(2);
    q.Push(3);
    // std::cout << q.GetTop() << std::endl;
    // q.Push(6);
    // q.Pop();
    // std::cout<<q.GetTop()<<std::endl;
    while (!q.IsEmpty())
    {
        std::cout << q.GetTop() << " ";
        q.Pop();
    }
    std::cout << std::endl;

    return 0;
}